home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 551-575 / disk_575 / pplib / oberoninterface / example.mod next >
Text File  |  1992-05-06  |  2KB  |  71 lines

  1. (* ------------------------------------------------------------------------
  2.   :Program.       Example
  3.   :Contents.      Demonstrates use auf Nico François' powerpacker.library
  4.   :Author.        Kai Bolay [kai] (C-Version by Nico François)
  5.   :Address.       Hoffmannstraße 168
  6.   :Address.       D-7250 Leonberg 1 (Germany)
  7.   :Address.       UUCP: ...!cbmvax!cbmehq!cbmger!depot1!amokle!kai
  8.   :Address.       FIDO: 2:247/706.3
  9.   :History.       v1.0 [kai] long ago  (translated from C)
  10.   :History.       v2.0 [kai] 22-Nov-91 (upated)
  11.   :Copyright.     Freeware
  12.   :Language.      Oberon
  13.   :Translator.    AMIGA OBERON v2.12e, A+L AG
  14.   :Remark.        Thanks to Nico for his great library
  15. ------------------------------------------------------------------------ *)
  16.  
  17. (*********************************
  18. *                                *
  19. *   powerpacker.library V35      *
  20. *                                *
  21. *   Release 2.0                  *
  22. *                                *
  23. *   (c) Mar 1991 Nico François   *
  24. *                                *
  25. *   Example.mod                  *
  26. *                                *
  27. *   This source is public domain *
  28. *   in all respects.             *
  29. *                                *
  30. *********************************)
  31.  
  32. MODULE Example;
  33.  
  34. IMPORT
  35.    pp: PowerPacker, e: Exec, io;
  36. CONST
  37.    file = "testfile";
  38. VAR
  39.    filestart: e.ADDRESS;
  40.    filelen: LONGINT;
  41.    err: LONGINT;
  42. BEGIN
  43.    filestart := NIL;
  44.    io.WriteString ("Loading file...\n");
  45.  
  46.    err := pp.LoadData (file, pp.DecrPoint, LONGSET {}, filestart, filelen, NIL);
  47.    IF err # pp.LoadOk THEN
  48.       CASE err OF
  49.       | pp.ReadErr: io.WriteString ("Error loading text file !\n");
  50.       | pp.NoMemory: io.WriteString ("No memory to decrunch file !\n");
  51.       | pp.PassErr: io.WriteString ("Incorrect password, loading aborted !\n");
  52.       | pp.OpenErr: io.WriteString ("Can't open file !\n");
  53.       | pp.UnknownPP: io.WriteString ("Crunched with unknown PP !\n");
  54.       ELSE
  55.          io.WriteString ("Unknown error !\n");
  56.       END; (* CASE *)
  57.    ELSE
  58.       io.WriteString ("file in memory, using it...\n");
  59.  
  60.       (* file is loaded at 'filestart' and can now be used *)
  61.  
  62.       (* ... *)
  63.  
  64.       io.WriteString ("done, freeing file...\n");
  65.    END; (* IF *)
  66. CLOSE
  67.    IF filestart # NIL THEN e.FreeMem (filestart, filelen); filestart := NIL END;
  68.  
  69.    io.WriteString ("exiting.\n");
  70. END Example.
  71.